<ul>
<?php

// parses all articles
foreach($db->pages->page as $page) {
  $text = $page->revision[count($page->revision)-1];
  $numwords = count(split(" ",$text));
  $revisions = count($page->revision);
  echo "    <page title='".$page['title']."' words='$numwords' revisions='$revisions'>\n";
  $split = split("}",$text);
  for($i=0; $i<count($split)-1; $i++) {
    $segment = $split[$i];
    $split2 = split("{",$segment);
    $final .= $split2[0];
    $linktarget = $split2[1];
    $linkbase = $page['title'];
    // print it out
    echo "<li>
    <a href='?show=$linkbase'>$linkbase</a>
     -> 
    <a href='?show=$linktarget'>$linktarget</a>
    </li>";
    // put it in the db
    //$dblink = $db->links->addChild("link");
    //$dblink->addAttribute("from",$linkbase);
    //$dblink->addAttribute("to",$linktarget);
    
  }
}

/*
// gets them from DB
foreach($db->links->link as $link) {
  $linkbase = $link['from'];
  $linktarget = $link['to'];
  echo "<li><a href='?show=$linkbase'>$linkbase</a> -> <a href='?show=$linktarget'>$linktarget</a></li>\n";
}
*/
?>
</ul>